﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using AssetAllocationSystem.Models;
using NHibernate;
using NHibernate.Criterion;

namespace AssetAllocationSystem.Repositories
{
    public class AssigneeRepository : RepositoryBase<Assignee>
    {
        private ISession session;
        public AssigneeRepository(ISession session)
            : base(session)
        {
            this.session = session;
        }

        public IList<Assignee> FindById(Guid id)
        {
            var assignee = DetachedCriteria
                .For<Assignee>()
                .Add(Restrictions.Eq("Id", id))
                .GetExecutableCriteria(session)
                .List<Assignee>();

            return assignee;
        }

        public IList<Assignee> FindByName(string name)
        {
            var assignee = DetachedCriteria
                .For<Assignee>()
                .Add(Restrictions.Like("Name", name))
                .GetExecutableCriteria(session)
                .List<Assignee>();

            return assignee;
        }
    }
}